package com.chen.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chen.entity.AccountA;
import com.chen.mapper.AccountAMapper;
import com.chen.service.AccountAService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

@Service
public class AccountAServiceImpl extends ServiceImpl<AccountAMapper,AccountA> implements AccountAService {
    @Resource
    private AccountAMapper accountAMapper;

    @Override
    public AccountA findAccountByUserId(int userId) {
        LambdaQueryWrapper<AccountA> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(com.chen.entity.AccountA::getUserId,userId);
        AccountA accountA = this.getOne(queryWrapper);
        return accountA;
    }

    @Override
    public int frozenDollarAmount(int userId, BigDecimal dollarAmount) {
        return accountAMapper.frozenDollarAmount(userId,dollarAmount);
    }

    @Override
    public void commitDollarToRmb(int userId, BigDecimal dollarAmount) {
        accountAMapper.commitDollarToRmb(userId,dollarAmount);
    }

    @Override
    public void cancelDollarToRmb(int userId, BigDecimal dollarAmount) {
        accountAMapper.cancelDollarToRmb(userId,dollarAmount);
    }

}
